<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link href="/layui/css/modules/layer/default/layer.css" rel="stylesheet"/>
</head>
<body>
<script src="/js/jquery.min.js"></script>
<script src="/js/config/server.js"></script>
<script src="/js/common/login.js"></script>
<script src="/layui/layui.all.js"></script>

<main id="topicList">

</main>


<script>
  var teacherId = sessionStorage.getItem('teacherId');
  handlerGet('/rest/topic/list/' + sessionStorage.getItem('teacherId'), 'teacher', function (data) {
    if (data.code === '0') {
      $("#topicList").html();
      data.data.forEach(function (item) {
        var status = '';
        if(item.status==='2'){
          status = '审核通过';
          $("#topicList").append('<blockquote class="layui-elem-quote">' + item.name + '  <span style="color: red">'+status+'</span></blockquote>');
        }else{
          $("#topicList").append('<blockquote class="layui-elem-quote" onclick="edit(' + item.topicId + ')">' + item.name + '</blockquote>');
        }
      });
    }
  }, function (data) {
    layer.msg('请检查网络连接' + data.responseText);
  });

  function edit(id) {
    layer.prompt({
      formType: 2,
      value: '输入备注',
      title: '提交审核',
      area: ['400px', '150px'] //自定义文本域宽高
    }, function (value, index, elem) {
      var data = {
        comment: value
      };

      handlerPost('/bus/teacher/submitCheck/' + id + '/' + teacherId, 'teacher',JSON.stringify(data), function (data) {
          if (data.code === '0') {
            layer.msg('提交审核成功，等待负责人回复')
          }
          if (data.code === '416') {
            layer.msg('请勿重复提交审核')
          }
        }, function (data) {
          layer.msg('提交失败，请检查网络并重试')
        }
      )
      ;
      layer.close(index);
    });
  }

</script>

</body>
</html>